package com.joca.scheduling.pages;

import java.util.Collection;
import java.util.List;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.joca.scheduling.database.ScheduleData;
import com.joca.scheduling.database.UserData;
import com.joca.scheduling.entities.Role;
import com.joca.scheduling.entities.Schedule;
import com.joca.scheduling.entities.User;
import com.joca.scheduling.hibernateservices.UserServiceHibernate;
import com.joca.scheduling.service.IUserServiceHibernate;

public class Student {

	@SessionState(create = false)
	@Property
	private User user;
	private boolean userExists;
	@Property
	private User professor;
	@Property
	private Schedule schedule;

	@Inject
	private IUserServiceHibernate iush;

	Object onActivate() {
		if (!userExists)
			return Index.class;
		else if (user.getRole() == Role.Student) {
			return null;
		}
		return Index.class;
	}

	public Collection<User> getAllUserProfessors() {
		return UserServiceHibernate.getUserServiceHibernate()
				.getAllUserProfessors();
		// return UserData.getInstance().getAllUserProfessors();
		// return iush.getAllUserProfessors();
	}

	public List<Schedule> getAllRepliedSchedules() {
		return UserServiceHibernate.getUserServiceHibernate()
				.getScheduleResponsesForStudent(user);
		// return
		// ScheduleData.getInstance().getScheduleResponsesForStudent(user);
	}
}
